package com.etc;

/**
 * @author: knowno
 * @create: 2024-09-05 11:08
 * @Version 1.0
 **/
public class TestMethod {
    public static void main(String[] args) {

        //.StackOverflowError 栈”溢出“
        //递归调用
        //main(null);

        int sum = getSum(5);
        System.out.println(sum);

    }

    /**
     * 递归方法 : 拆,合
     * @param n
     * @return
     */
    public static int getSum(int n) {
        if (n == 1) {
            //方法终止条件
            return 1;
        }
        // 递归
        return n * getSum(n - 1);
    }
}
